<template>
  <div class="container">
    <!-- 头部 -->
    <!-- 当路由地址（path === $route.path）不是`我的`才显示 -->
    <van-nav-bar
      v-if="this.$route.path !== '/user'"
      fixed
      title="黑马头条"
      right-text="搜索"
      @click-right="$router.push('/search')"
    />
    <!-- 中间内容：二级路由挂载点=》注意容器样式添加 -->
    <div class="my-wrapper" :class="{ noTop: this.$route.path === '/user' }">
      <router-view></router-view>
    </div>
    <!-- 底部菜单 -->
    <van-tabbar route>
      <van-tabbar-item to="/" icon="home-o">首页</van-tabbar-item>
      <van-tabbar-item to="/question" icon="chat-o">问答</van-tabbar-item>
      <van-tabbar-item to="/video" icon="video-o">视频</van-tabbar-item>
      <van-tabbar-item to="/user" icon="user-o">我的</van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
export default {
  // created () {
  //   console.log(this.$route)
  // }
}
</script>

<style scoped lang='less'>
.container {
  width: 100%;
  height: 100%;
  position: relative;
  .my-wrapper {
    width: 100%;
    height: 100%;
    overflow: hidden;
    padding-top: 46px;
    padding-bottom: 50px;
    box-sizing: border-box;
    &.noTop {
      padding-top: 0;
    }
  }
}
</style>
